package com.jml.jdbc.demo;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

//数据库连接池这些都是连接都是放在阻塞队列中从而进行重复使用，只要是大小不超过最大空闲就可以了，释放连接就是把连接放入队列，超出队列范围就会close连接
public class MainTest {
	public static void main(String[] args) {
		ApplicationContext act = new ClassPathXmlApplicationContext("/jdbc/datasource.xml");
		UserService userService = (UserService)act.getBean("userService");
		User user = new User(1,"nn",2,"s");
		userService.save(user);

		List<User> user1 = userService.getUser();
		for (User us : user1) {
			System.out.println(us.getName());
			System.out.println(us.getAge());
			System.out.println(us.getSex());
			System.out.println(us.getId());
		}
	}
}
